import * as React from 'react';

export default class LazyRenderBox extends React.Component {
  shouldComponentUpdate(nextProps) {
    if (nextProps.forceRender) {
      return true;
    }
    return !!nextProps.hiddenClassName || !!nextProps.visible;
  }
  render() {
    const { className, hiddenClassName, visible, forceRender, ...restProps } = this.props;
    let useClassName = className;
    if (!!hiddenClassName && !visible) {
      useClassName += ` ${hiddenClassName}`;
    }
    return <div {...restProps} className={useClassName} />;
  }
}